#ifndef xExportVertex_h_h_h_h_h_h
#define xExportVertex_h_h_h_h_h_h
#include "stdafx.h"
#include "COLLADAFW.h"
#include "COLLADASaxFWLLoader.h"
#include "xBaseWrite.h"

namespace XE
{


	typedef std::vector<xVector2> UVVector;
	typedef std::vector<xColor> ColorVector;	
	typedef std::vector<COLLADAFW::MaterialId>MaterialidVector;



	class xExportVertex
	{
	public:
		xExportVertex(void)
			:m_HasNormal(false)
		{

		}
		~xExportVertex(void);


		xVector3 m_Posindex;
		xVector3  m_NormalIndex;
		UVVector m_UVVector;
		ColorVector m_ColorVector;
		bool m_HasNormal;

	};



	bool operator==(const xExportVertex& v1,const xExportVertex v2);



	typedef std::vector<xExportVertex> xSubMeshVertexs;

	typedef std::vector<xSubMeshVertexs*>xMeshVertexVector;

    typedef std::vector<UINT>  xSubMeshIndexs;

	typedef std::vector<xSubMeshIndexs*> xMeshIndexsVector;



	class xMeshWrite :public xBaseWrite
	{
	public:
		xMeshWrite(xEngineWrite* pEngineWrite,xSceneManager* pSceneMgr,  COLLADAFW::Mesh*pColladaMesh);

		~xMeshWrite();


		bool write();

		bool writeSubMesh(COLLADAFW::MeshPrimitive* pmeshPrimitive);


	    void addFace(xSubMeshVertexs* pSubVertex,xSubMeshIndexs* pSub,COLLADAFW::Triangles* pTriangles,size_t FaceIndex);

		//----return vertex index in the subvertex
		int addVertex(xSubMeshVertexs* pSubVertex,const xExportVertex& v1);

		bool buildmesh();

		bool HasNormal() const ;

		size_t GetMapChannleCount();

		size_t GetVertexColorCount();



	protected:




        xMeshVertexVector m_MeshVertexs;
		xMeshIndexsVector m_MeshIndex;

		MaterialidVector m_MaterialId;

		DWORDVector m_FaceMaterialID;

        xSceneManager* m_pSceneMgr;
		 COLLADAFW::Mesh* m_pColladaMesh;

		


	};








}

#endif	